package com.backstage.util;

import java.util.Map;

/**
 * Created by YSTen on 2017/7/16.
 */
public class ReturnUtil {
    public static final String SUCCESS_CODE = "200";

    public static final String SUCCESS_STATUS = "success";

    public static final String SUCCESS_MESSAGE = "成功";

    public static final String ERROR_CODE = "503";

    public static final String ERROR_STATUS = "error";


    /**
     * 成功信息返回
     *
     * @param message
     * @param data
     * @return
     */
    public static Map resSuccesssMap(String message, Object data) {
        Map resMap = MiscUtil.toMap();
        resMap.put("status", SUCCESS_STATUS);
        resMap.put("message", message);
        resMap.put("resCode", SUCCESS_CODE);
        if (null != data) {
            resMap.put("data", data);
        }

        return resMap;
    }

    /**
     * 出错信息返回
     *
     * @param message
     * @return
     */
    public static Map resErrorMap(String message) {
        Map resMap = MiscUtil.toMap();
        resMap.put("status", ERROR_STATUS);
        resMap.put("message", message);
        resMap.put("resCode", ERROR_CODE);
        return resMap;
    }
}
